<?php
require_once 'Zend/Uri.php';

/**
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file license.txt or that can be found at 
 * http://code.google.com/p/billboardce/wiki/License.
 *
 * @package    Ot_Validate_Uri
 * @category   Library
 * @license    http://code.google.com/p/billboardce/wiki/License New BSD License
 * @version    SVN: $Id: $
 */

/**
 * validates a URI for use in a Zend_Form
 *
 * @package    Ot_Validate_Uri
 * @category   Library
 */
class Ot_Validate_Uri implements Zend_Validate_Interface
{
    
    /**
     * error messages
     *
     * @var array
     */
    protected $_messages = array();

    public function isValid($value)
    {
        // Validate the URI
        $valid = Zend_Uri::check($value);
        
        // Return validation result TRUE|FALSE   
        if ($valid)  {
            return true;
        } else {
            $this->_messages[] = 'Invalid URI';
            return false;
        }

    }
    
    /**
     * gets error messages
     *
     * @return array
     */
    public function getMessages()
    {
        return $this->_messages;
    }
    /**
     * gets error messages
     *
     * @return array
     */
    public function getErrors()
    {
        return $this->_messages;
    }
}